home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
KBSETUP.ARJ
/
KBSETUP.C
next >
Wrap
C/C++ Source or Header
|
1992-06-13
|
3KB
|
80 lines
/*
*****************************************************************
* program: KBSETUP.C programmer: Andy Kellett *
* written: 05/16/91 using Turbo C v2.0 *
* This program allows changing the keyboard key-repeat rate *
* (delay and speed) for AT and compatibles, also PS/2 models. *
* Will not work on PC or XT models. PC World p.251-252 12/90 *
* original Turbo C version by Michael O'Connor *
* last updated: 06/13/91 Converted back to TC from PowerC *
*****************************************************************
*/
#include <ctype.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#define ISIN(l,h,v) ((l<=v)&&(v<=h))
int kbdelay = 0; /* Default typematic delay */
int kbrepeat = 0; /* Default repeat rate */
void usage(void)
{
puts("ERROR: Type KBSETUP M for menu\n");
exit(1);
}
void menu(void)
{
/*----- problems? Prompt user with usage help -----*/
clrscr();
printf("\n\tKBSETUP MENU: Michael O'Connor using TurboC v2.0\n");
printf("\t keyboard DELAY time == delay in msecs\n");
printf("\t A == 250\n");
printf("\t B == 500\n");
printf("\t C == 750\n");
printf("\t D == 1000\n");
printf("\tkeyboard REPEAT rate == characters per second\n");
printf("0 == 30.0\t 8 == 15.0\t 16 == 7.5\t 24 == 3.7\n");
printf("1 == 26.7\t 9 == 13.3\t 17 == 6.7\t 25 == 3.3\n");
printf("2 == 24.0\t 10 == 12.0\t 18 == 6.0\t 26 == 3.0\n");
printf("3 == 21.8\t 11 == 10.9\t 19 == 5.5\t 27 == 2.7\n");
printf("4 == 20.0\t 12 == 10.0\t 20 == 5.0\t 28 == 2.5\n");
printf("5 == 18.5\t 13 == 9.2\t 21 == 4.6\t 29 == 2.3\n");
printf("6 == 17.1\t 14 == 8.6\t 22 == 4.3\t 30 == 2.1\n");
printf("7 == 16.0\t 15 == 8.0\t 23 == 4.0\t 31 == 2.0\n");
printf("\tSyntax: kbsetup <A...D> <0...31>\n");
printf("\tDefault settings: A 0 (short delay, fast repeat)\n");
exit(1);
}
void main(int argc, char *argv[])
{
int i;
union REGS reg;
if (toupper(argv[1][0])== 'M') menu();
else for (i = 1; i < argc; i++)
if (isdigit(*argv[i])) {
kbrepeat = atoi(argv[i]);
if (!ISIN(0, 31, kbrepeat)) usage();
} else {
argv[i][0] = toupper(argv[i][0]);
if (!ISIN('A', 'D', argv[i][0])) usage();
kbdelay = argv[i][0] - 'A';
}
/*----- SET THE AX REGISTER TO 0305h, BH REGISTER TO DELAY VALUE -----
----- BL TO TYPEMATIC RATE, THEN CALL INT 16h, FUNCTION 0305h ----- */
reg.x.ax = 0x0305;
reg.h.bh = kbdelay;
reg.h.bl = kbrepeat;
int86(0x16, ®, ®);
printf("\tSyntax: kbsetup <A...D> <0...31>\n");
printf("\tDefault settings: A 0 (short delay, fast repeat)\n");
}